// package grpcclientdemo

package main

import (
	"context"
	"fmt"

	opb "gPublic/grpc/yz-pub-data/openData"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func main() {
	conn, err := grpc.Dial("127.0.0.1:5904", grpc.WithTransportCredentials(insecure.NewCredentials()))

	if err != nil {
		fmt.Printf("did connect fail: %v", err)
	}

	defer conn.Close()

	client := opb.NewOpenDataClient(conn)
	res, err := client.GetOpeData(context.Background(), &opb.OpenRequest{SourceType: "pc"})

	if err != nil {
		fmt.Println("客户端访问异常：", err)
		//  rpc error: code = Unimplemented desc = method GetOpeData not implemented 没有实现grpc的服务的方法【可能是方法名称写错了，修改一致即可】
		// rpc error: code = Unavailable desc = error reading from server: EOF 服务器问题
	}

	fmt.Println(res.GetPartnerList())
	fmt.Println(res.GetWebMenus())
}
